export default {
    /**
     * alert 弹框
     * @param content
     * @param option
     */
    alert(content, option = {}) {
        let defaultOption = {
        	confirmColor: "#FF8900",
        	title: option.title ? option.title : "提示",
        	content: content,
        	showCancel: false
        };
        option = Object.assign(option, defaultOption);
        return uni.showModal(option);
    },

    /**
     * confirm 弹框
     * @param content
     * @param option
     */
    confirm(content, option = {}) {
        let defaultOption = {
            confirmColor: "#FF8900",
        	title: option.title ? option.title : "提示",
        	content: content,
        	showCancel: true
        };
        option = Object.assign(option, defaultOption);
        let promise = new Promise((resolve, reject) => {
        	uni.showModal(option).then(res => {
        		if (res.confirm) {
        			resolve()
        		} else {
        			reject();
        		}
        	}).catch(res => {
        		reject();
        	})
        })
        return promise;
    },

    /**
     * loading 样式
     * @param msg
     */
    loading(msg, mask) {
        if (!msg) {
        	uni.hideLoading();
        	return;
        }

        uni.showLoading({
        	title: msg,
        	mask: mask,
        })
    },

    /**
     * 成功
     * @param msg
     */
    success(msg) {
        uni.showToast({
        	title: msg,
        	icon: "none",
        	mask: true
        })
    },

    /**
     * 失败
     * @param msg
     */
    error(msg) {
        uni.showToast({
        	title: msg,
        	icon: "none",
        	mask: true
        })
    }
}
